import  { AppPostT } from '@/utils/request'
import { Message, MessagePageResult } from '@/models/message'
import { ActionResult, BasicPageSearch } from '@/models/basicType'

// 获得消息列表
export async function getMessage(data:BasicPageSearch) {
    return AppPostT<MessagePageResult>("/sysMsg/page",data)
}

// 获取指定消息
export async function getMessageById(id:number) {
    return AppPostT<Message>("/sysMsg/detail",{id:id})
}

// 把消息设置为已读
export async function setMessageAsRead(id:number) {
    return AppPostT<ActionResult>("/sysMsg/read",{id:id})
}

// 删除指定消息
export async function deleteMessageById(id:number) {
    return AppPostT<ActionResult>("/sysMsg/del",{id:id})
}

// 批量指定消息
export async function deleteMessageAll(ids:number[]) {
    return AppPostT<ActionResult>("/sysMsg/del",{ids:ids})
}

// 未读条数
export async function getUnreadCount() {
    const data = {}
    const res = await AppPostT<number>("/sysMsg/unReadCount", data)
    console.log("getUnreadCount request:", data, ", result:", res)
    return res?.data || 0
}
